package com.itheima.demo001;

public class exercise38 {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9};
        int[] arr1 = new int[0];
        int[] copyArr = copyOfRange(arr,3,7);
        for (int i = 0; i < copyArr.length; i++) {
            System.out.print(copyArr[i] + " ");
        }
    }
    public static int[] copyOfRange(int[] arr, int form, int to){
        int index = 0;
        //伪造索引（变量）
        int[] newArr = new int[to - form];
        for (int i = form; i < to; i++) {
            newArr[index] = arr[i];
            index++;
        }
        return newArr;
    }
}
